import { withScopeId, getCurrentInstance } from "vue"

export function useScopeId() {
    const instance = getCurrentInstance()
    if (!instance) {
        throw new Error(`useScopeId is called without current active component instance.`)
    }
    return (instance.type as any).__scopeId
}

export function useWithScopeId() {
    let id = useScopeId()
    if(id) {
        return withScopeId(id)
    }
    throw new Error("unknow scopeid") 
}

